package com.woniuxy.caradmin.controller;

import com.sun.org.apache.xpath.internal.operations.Mod;
import com.sun.org.apache.xpath.internal.operations.Mod;
import com.woniuxy.caradmin.entity.pojo.Dept;
import com.woniuxy.caradmin.entity.pojo.User;
import com.woniuxy.caradmin.service.DeptService;
import com.woniuxy.caradmin.service.UserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Controller
public class JumpController {
    @Autowired
    private UserService userService;

    //跳转用户界面
    @ApiOperation("跳转用户界面")
    @RequestMapping("/gouserList")
    public String gouserList(){
        System.out.println("fsfsd");
        return "userList";
    }
    //跳转到角色列表
    @ApiOperation("跳转到角色列表")
    @RequestMapping("/rolelist")
    public ModelAndView Role(ModelAndView modelAndView){
        modelAndView.setViewName("rolelist");
        return modelAndView;
    }
    //跳转到驾驶员档案列表
    @ApiOperation("跳转到驾驶员档案列表")
    @RequestMapping("/driverlist")
    public ModelAndView driver(ModelAndView modelAndView){
        modelAndView.setViewName("driverlist");
        return modelAndView;
    }
    //跳转违章记录页面
    @RequestMapping("/gobreak")
    public ModelAndView gobreak(ModelAndView modelAndView) {
        modelAndView.setViewName("breakrulerecord");
        return modelAndView;
    }
    //跳转事故记录页面
    @RequestMapping("/gotrouble")
    public ModelAndView gotrouble(ModelAndView modelAndView) {
        modelAndView.setViewName("troublerecord");
        return modelAndView;
    }
    //跳转年检记录页面
    @RequestMapping("/goyear")
    public ModelAndView goyear(ModelAndView modelAndView) {
        modelAndView.setViewName("yearcheckrecord");
        return modelAndView;
    }
    //跳转保险记录页面
    @RequestMapping("/goinsure")
    public ModelAndView goinsure(ModelAndView modelAndView) {
        modelAndView.setViewName("insurerecord");
        return modelAndView;
    }
    //跳转更新年检记录页面
    @RequestMapping("/goupyear")
    public ModelAndView goupyear(ModelAndView modelAndView) {
        modelAndView.setViewName("upyearcheckrecord");
        return modelAndView;
    }
    //跳转增加违章记录页面
    @RequestMapping("/goaddbreak")
    public ModelAndView goaddbreak(ModelAndView modelAndView) {
        modelAndView.setViewName("addbreakrecord");
        return modelAndView;
    }
    //跳转增加年检记录页面
    @RequestMapping("/goaddyear")
    public ModelAndView goaddyear(ModelAndView modelAndView) {
        modelAndView.setViewName("addyearcheckrecord");
        return modelAndView;
    }
    //跳转增加事故记录页面
    @RequestMapping("/goaddtrouble")
    public ModelAndView goaddtrouble(ModelAndView modelAndView) {
        modelAndView.setViewName("addtroublerecord");
        return modelAndView;
    }
    //跳转增加保险记录页面
    @RequestMapping("/goaddinsure")
    public ModelAndView goaddinsurerecord(ModelAndView modelAndView) {
        modelAndView.setViewName("addinsurerecord");
        return modelAndView;
    }
    //跳转至到期提醒页面
    @RequestMapping("/remind")
    public ModelAndView remind(ModelAndView modelAndView){
        modelAndView.setViewName("remind");
        return modelAndView;
    }
    //跳转至车辆状态页面
    @RequestMapping("/carstatus")
    public ModelAndView carstatus(ModelAndView modelAndView){
        modelAndView.setViewName("carstatus");
        return modelAndView;
    }
    //跳转至增加车辆页面
    @RequestMapping("/goAddVehiclefile")
    public ModelAndView goAddVehiclefile(ModelAndView modelAndView){
        modelAndView.setViewName("addVehiclefile");
        return modelAndView;
    }
    //跳转至修改车辆页面
    @RequestMapping("/goUpdateVehiclefile")
    public ModelAndView goUpdateVehiclefile(ModelAndView modelAndView){
        modelAndView.setViewName("updateVehiclefile");
        return modelAndView;
    }
    //跳转至车辆详情页面
    @RequestMapping("/goDetailVehiclefile")
    public ModelAndView goDetailVehicle(ModelAndView modelAndView){
        modelAndView.setViewName("detailVehiclefile");
        return modelAndView;
    }
    //跳转到用户角色分配页面
    @ApiOperation("跳转到用户角色分配页面")
    @RequestMapping("/goRoles")
    public ModelAndView goRoles(ModelAndView modelAndView){
        modelAndView.setViewName("userRole");
        return modelAndView;
    }
    //跳转到角色分配权限页面
    @ApiOperation("跳转到角色分配权限页面")
    @RequestMapping("/gorolePermiss")
    public ModelAndView gorolePermiss(ModelAndView modelAndView){
        modelAndView.setViewName("gorolePermiss");
        return modelAndView;
    }
    //跳转用户增加页面
    @RequestMapping("/adduser")
    @ApiOperation("跳转用户增加页面")
    public ModelAndView adduser(ModelAndView modelAndView){
        modelAndView.setViewName("adduser");
        return modelAndView;
    }
    //跳转用户修改页面
    @RequestMapping("/updateuser/{id}")
    @ApiOperation("跳转用户修改页面")
    public ModelAndView updateuser(@PathVariable("id") String id, ModelAndView modelAndView, HttpServletRequest request){
        System.out.println("+++"+id);
        User user = userService.selectUserByid(Integer.parseInt(id));
        request.setAttribute("name",user.getName());
        System.out.println(user);
        modelAndView.setViewName("updateuser");
        return modelAndView;
    }
    //跳转角色增加页面
    @RequestMapping("/addrole")
    @ApiOperation("跳转角色增加页面")
    public ModelAndView addrole(ModelAndView modelAndView){
        modelAndView.setViewName("addrole");
        return modelAndView;
    }
    //跳转角色修改页面
    @RequestMapping("/updrole")
    @ApiOperation("跳转角色修改页面")
    public ModelAndView updrole(ModelAndView modelAndView){
        modelAndView.setViewName("updrole");
        return modelAndView;
    }
    //跳转更新违章事故记录页面
    @RequestMapping("/goupbreak")
    public ModelAndView goupbreak(ModelAndView modelAndView) {
        modelAndView.setViewName("upbreakrulerecord");
        return modelAndView;
    }
    //跳转更新保险记录页面
    @RequestMapping("/goupinsure")
    public ModelAndView goupinsure(ModelAndView modelAndView) {
        modelAndView.setViewName("upinsurerecord");
        return modelAndView;
    }
    //跳转更新事故记录页面
    @RequestMapping("/gouptrouble")
    public ModelAndView gouptrouble(ModelAndView modelAndView) {
        modelAndView.setViewName("uptroublerecord");
        return modelAndView;
    }

    //跳转至车辆照片页面
    @RequestMapping("/goImgmanaVehiclefile")
    public ModelAndView goImgmanaVehiclefile(ModelAndView modelAndView){
        modelAndView.setViewName("imgmanaVehiclefile");
        return modelAndView;
    }
}
